package com.itheima.wms.common.enums;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public enum StockRecordWay {

    POSITIVE("+", "+"),
    NEGATIVE("-", "-"),
    FROZEN("frozen", "冻结"),
    UNFREEZE("unfreeze", "解冻");


    StockRecordWay(String code, String value) {

        this.code = code;
        this.value = value;
    }

    /**
     * 类型编码
     */
    private final String code;

    /**
     * 类型值
     */
    private final String value;


    public String getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }


    /**
     * 循环变量
     */
    private static final Map<String, StockRecordWay> LOOKUP = new HashMap<>();

    //静态初始化
    static {

        for (StockRecordWay statusEnum : EnumSet.allOf(StockRecordWay.class)) {

            LOOKUP.put(statusEnum.code, statusEnum);
        }
    }

    /**
     * 根据code获取枚举项
     *
     * @param code 值
     * @return 值
     */
    public static StockRecordWay lookup(String code) {
        return LOOKUP.get(code);
    }
}
